<template>
  <div>
    <select class="form-control" v-model="internalSelectedPolicy" @change="change">
      <option v-for="option in this.policies" v-bind:value="option.id">{{ option.name }}</option>
    </select>
  </div>
</template>

<script>
// import VueResource from 'vue-resource'
export default {
  name: 'Policy',
  props: ['selectedPolicy','withUnlimit'],
  components: {
    // VueResource
  },
  data: function () {
    return {
      internalSelectedPolicy: this.selectedPolicy,
      policies: []
    }
  },
  methods: {
    getpolicyname(id) {
      for (var index in this.policies) {
        if (this.policies[index].id == id) {
          return this.policies[index].name;
        }
      }
      return ''
    },
    loaddata: function () {
      if (this.withUnlimit) {
        this.policies = [{ id: -1, name: '不限' }]
        this.policies = this.nationals.concat(this.sysconfigs.politicalStatus)
      }
      else
        this.policies = this.$store.state.sysconfigs.politicalStatus
    },
    change: function (ele) {
      this.$emit('policychange', this.internalSelectedPolicy)
    }
  },
  created: function () {
    this.loaddata()
  }
}
</script>
